<script>
	import update from '@/tool/update.js'
	//引入vuex
	import { mapMutations } from 'vuex'
	export default {
		onLaunch: function() {
			update(this.$baseUrl)
			//获取基础信息list
			this.getconfig()
			console.log('App Launch')
			//定义一个路由白名单
			const whitelist = ['/page/login/login', '/page/login/codeLogin', '/page/login/forgetPwd',
				'/page/login/register', '/page/login/xieyi'
			]
			const token = uni.getStorageSync('token')
			uni.addInterceptor('request', {
				invoke(args) {
					console.log(args)
					if (!whitelist.indexOf(args.url) == -1 && !token) {
						// this.$msg('请您登录')
						console.log('aaa', whitelist.indexOf(args.url) == -1)
						uni.reLaunch({
							url: '/pages/login/login'
						})
					}
				},
			})
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			...mapMutations('m_config', ['getConfig']),
			//获取基础信息
			getconfig() {
				this.getConfig()
			}
		}
	}
</script>


<style lang="scss">
	@import "uview-ui/index.scss";
	@import "static/style/common.scss";
	@import "static/style/icon.css"; // 图标库   链接https://www.cnblogs.com/yyh28/p/13524096.html 
</style>
